// index.js

import request from '../../utils/request'
Page({
  data: {
    bannerList:[],
    recommendList:[], // 推荐歌单
    topList:[],//排行榜数据
  },
  // 事件处理函数
  bindViewTap() {

  },
 async onLoad(){
let bannerListData =await request("/banner",{type:1})
bannerListData=bannerListData.data
let recommendListData =await request("/personalized",{limit:10})
recommendListData=recommendListData.data
let index=0;
let resultArr=[];

while(index<4){

  let topListData=await request('/toplist/detail')
  console.log(topListData,"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
  topListData=topListData.data
  let topListItem={name:topListData.list[index].name,coverImgUrl:topListData.list[index].coverImgUrl,tracks:topListData.list[index].tracks,id:topListData.list[index].id}
  resultArr.push(topListItem) 
  index++
}

this.setData({
  bannerList:bannerListData.banners,
  recommendList:recommendListData.result,
  topList:resultArr
})

  },
  toTodetail(e){
    
    wx.navigateTo({
      url: `/pages/Top/Top?id=${e.currentTarget.id}`,
    })
  },
  tosearch(){
    wx.navigateTo({
      url: '/pages/Search/Search',
    })
  },

  getUserProfile(e) {
   
  },
  getUserInfo(e) {


  }
})
